

function celBten() {
    location.href="./index.html"
}
function btnAdd() {
    location.href="./addOrUpd.html"
} 
async function saveBten() {
    let id=new URLSearchParams(window.location.search).get('id') || 0
    console.log(id);
    let bookName=$(`[name="bookName"]`).val()
    let bookPirce=$(`[name="bookPirce"]`).val()
    let bookAuthor=$(`[name="bookAuthor"]`).val()
    let res
    console.log(bookName,bookPirce,bookAuthor);
    if (id) {
      res=  await axios.put(`http://localhost:5000/book/${id}`,{bookName,bookPirce,bookAuthor})
    }else{
        res= await axios.post(`http://localhost:5000/book`,{bookName,bookPirce,bookAuthor})
    }
    if (res.data.code===1000) {
        location.href=`./index.html`
    }
    
console.log(res);


    
    }